
rm -rf build-dir
mkdir build-dir
cd build-dir
CFLAGS="$DRACOSRC_FLAGS" \
CXXFLAGS="$DRACOSRC_CFLAGS" \
../dist/configure \
  --prefix=/usr \
  --enable-shared \
  --enable-rpc \
  --enable-cxx \
  --enable-compat185 \
  $DRACOSRC_ARCH-draco-linux || exit 1

make -j3 || exit 1
make install DESTDIR=$DRACOSRC_PKG || exit 1

rm -rf $DRACOSRC_PKG/usr/docs

( cd $DRACOSRC_PKG/usr/include
  mkdir db46
  mv *.h db46
  for file in db46/* ; do
    ln -sf $file .
  done
  ln -sf db46 db4
)

mkdir -p $DRACOSRC_PKG/lib
mv $DRACOSRC_PKG/usr/lib/libdb-4.6.so $DRACOSRC_PKG/lib/libdb-4.6.so || exit 1
( cd $DRACOSRC_PKG/usr/lib
  ln -sf /lib/libdb-4.6.so .
)

( cd $DRACOSRC_PKG/usr/lib
  ln -sf libdb-4.6.a libdb-4.a
  ln -sf libdb-4.6.a libdb4.a
  ln -sf libdb-4.6.a libdb.a
  ln -sf libdb_cxx-4.6.a libdb_cxx-4.a
  ln -sf libdb_cxx-4.6.a libdb_cxx.a
  ln -sf libdb-4.6.so libdb4.so
  ln -sf libdb-4.6.so libdb.so

  #ln -sf libdb-4.5.so libdb-4.4.so
)

chmod 755 $DRACOSRC_PKG/usr/bin/*
